package www.cslc.com.Game.ui.commonBetui;

import java.awt.FlowLayout;
import java.util.List;

import javax.swing.JPanel;

@SuppressWarnings("serial")
public class SelectNumPanel extends JPanel {
	@SuppressWarnings("rawtypes")
	private List ballList;
	private String[] numKey;
	private String[] numValue;
	@SuppressWarnings({ "rawtypes", "unused" })
	private Class ballClass;
	private int maxSelectedNum = 0;

	@SuppressWarnings("rawtypes")
	public SelectNumPanel(String[] number, List ballList, Class ballClass,int maxSelectedNum) {
		this.numKey = number;
		this.numValue = number;
		this.ballList = ballList;
		this.ballClass = ballClass;
		if(number != null && number.length != 0 && ballList != null){
			this.setLayout(new FlowLayout(FlowLayout.LEFT));
			for (int i = 0; i < number.length; i++) {
				RButton ball = null;
				if(ballClass.equals(RedBall.class)){
					ball = new RedBall(number[i],number[i]);
				}else if(ballClass.equals(BlueBall.class)){
					ball = new BlueBall(number[i],number[i]);
				}else{
					ball = new RButton(number[i]);
				}
				ball.setSelectedBallList(ballList);
				ball.setMaxSelectedNum(maxSelectedNum);
				this.add(ball);
			}
		}
	}
	
	@SuppressWarnings("rawtypes")
	public SelectNumPanel(String[] numKey,String[] numValue, List ballList, Class ballClass,int maxSelectedNum) {
		this.numKey = numKey;
		this.numValue = numValue;
		this.ballList = ballList;
		this.ballClass = ballClass;
		if(numKey != null && numKey.length != 0 && numValue != null && numValue.length != 0 && numKey.length == numValue.length && ballList != null){
			this.setLayout(new FlowLayout(FlowLayout.LEFT));
			for (int i = 0; i < numKey.length; i++) {
				RButton ball = null;
				if(ballClass.equals(RedBall.class)){
					ball = new RedBall(numKey[i],numValue[i]);
				}else if(ballClass.equals(BlueBall.class)){
					ball = new BlueBall(numKey[i],numValue[i]);
				}else{
					ball = new RButton(numKey[i],numValue[i]);
				}
				ball.setSelectedBallList(ballList);
				ball.setMaxSelectedNum(maxSelectedNum);
				this.add(ball);
			}
		}
	}
	@SuppressWarnings("rawtypes")
	public List getBallList() {
		return ballList;
	}
	@SuppressWarnings("rawtypes")
	public void setBallList(List ballList) {
		this.ballList = ballList;
	}

	public int getMaxSelectedNum() {
		return maxSelectedNum;
	}

	public void setMaxSelectedNum(int maxSelectedNum) {
		this.maxSelectedNum = maxSelectedNum;
	}
	public String[] getNumKey() {
		return numKey;
	}
	public void setNumKey(String[] numKey) {
		this.numKey = numKey;
	}
	public String[] getNumValue() {
		return numValue;
	}
	public void setNumValue(String[] numValue) {
		this.numValue = numValue;
	}
}
